package org.lzy.aibg.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.lzy.aibg.mapper.EmployeeMapper;
import org.lzy.aibg.pojo.Employee;
import org.lzy.aibg.service.EmployeeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {
    // 说明：请根据EmployeeService中的接口，在本类中实现所有接口

    // 1.TO-DO: mapper自动注入
    @Autowired
    private EmployeeMapper employeeMapper;
    // 2.TO-DO: 完成根据id获取Employee的service函数编写
    @Override
    public Employee getById(Integer id) {
        return employeeMapper.selectByPrimaryKey(Long.valueOf(id));
    }
    // 3.TO-DO: 完成查询所有Employee的Service函数编写
    @Override
    public List<Employee> list() {
        return employeeMapper.listAll();
    }
    // 4.TO-DO: 完成根据id删除Employee的service函数编写
    @Override
    public Integer removeById(Integer id) {
        return employeeMapper.deleteByPrimaryKey(Long.valueOf(id));
    }
    // 5.TO-DO: 完成更新员工信息的service函数编写
    @Override
    public Integer update(Employee employee) {
        return employeeMapper.updateByPrimaryKey(employee);
    }
    // 6.TO-DO: 完成新增员工（save）的service函数编写
    @Override
    public Integer save(Employee employee) {
        return employeeMapper.insert(employee);
    }
    // 7.TO-DO: 完成获取员工总数的service函数编写
    @Override
    public Integer count() {
        return employeeMapper.count();
    }
    // 8.TO-DO: 完成员工列表分页查询
    @Override
    public List<Employee> listByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        return null;
    }

}
